package be.jprojects.subscription.gui.i18n;



import javax.swing.JLabel;

import be.jprojects.subscription.controllers.LanguageController;
import be.jprojects.subscription.controllers.ListenersController;
import be.jprojects.subscription.gui.listeners.SelectedLanguageChangeListener;

public class TranslatableLabel extends JLabel implements SelectedLanguageChangeListener {
	private String text;
	
	public TranslatableLabel() {
		this("");
	}

	public TranslatableLabel(String text) {
		super(LanguageController.getInstance().translate(text));
		this.text = text;
		setOpaque(false);
		ListenersController.getInstance().addLanguageChangeListener(this);
	}
	
	public void setText(String text) {
		this.text = text;
		super.setText(LanguageController.getInstance().translate(text));
	}

	public void selectedLanguageChanged() {
		super.setText(LanguageController.getInstance().translate(text));
	}
}